﻿using System;
using System.Data;

namespace DAL
{
    public static class DalContract
    {
        private static readonly clsConnect Cls = new clsConnect();
        #region[Get-Data]
        public static DataTable GetContract(string keywords)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@KEYWORDS", keywords);
            return Cls.GetData("sp_Contract_Get");
        }
        public static DataTable GetContractEdit(int id)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@Contract_ID", id);
            return Cls.GetData("sp_Contract_Get_Edit");
        }
        #endregion

        #region[Insert-Update-Delete]
        public static bool Insert(EtContract obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@TypeContract_ID", obj.TypeContract_ID);
            Cls.AddParameter("@Job_ID", obj.Job_ID);
            Cls.AddParameter("@Employee_Id", obj.Employee_Id);
            Cls.AddParameter("@Contract_Code", obj.Contract_Code);
            Cls.AddParameter("@DateBegin", obj.DateBegin);
            Cls.AddParameter("@Contract_Name", obj.Contract_Name);
            Cls.AddParameter("@Contract_Job", obj.Contract_Job);
            Cls.AddParameter("@Contract_National", obj.Contract_National);
            Cls.AddParameter("@Contract_Identification", obj.Contract_Identification);
            Cls.AddParameter("@Contract_Company", obj.Contract_Company);
            Cls.AddParameter("@Contract_Address", obj.Contract_Address);
            Cls.AddParameter("@Contract_Phone", obj.Contract_Phone);
            Cls.AddParameter("@Contract_Fax", obj.Contract_Fax);
            Cls.AddParameter("@Contract_TimeWork", obj.Contract_TimeWork);
            Cls.AddParameter("@Contract_Wage", obj.Contract_Wage);
            Cls.AddParameter("@Contract_Vacation", obj.Contract_Vacation);
            Cls.AddParameter("@Contract_Interest", obj.Contract_Interest);
            Cls.AddParameter("@Contract_DateBegin", obj.Contract_DateBegin);
            Cls.AddParameter("@Contract_DateEnd", obj.Contract_DateEnd);
            Cls.AddParameter("@Contract_File", obj.Contract_File);
            Cls.AddParameter("@Contract_Node", obj.Contract_Node);
            return Cls.ExecuteNonQuery("sp_Contract_Insert");
        }
        public static bool Update(EtContract obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@Contract_ID", obj.Contract_ID);
            Cls.AddParameter("@TypeContract_ID", obj.TypeContract_ID);
            Cls.AddParameter("@Job_ID", obj.Job_ID);
            Cls.AddParameter("@Employee_Id", obj.Employee_Id);
            Cls.AddParameter("@Contract_Code", obj.Contract_Code);
            Cls.AddParameter("@DateBegin", obj.DateBegin);
            Cls.AddParameter("@Contract_Name", obj.Contract_Name);
            Cls.AddParameter("@Contract_Job", obj.Contract_Job);
            Cls.AddParameter("@Contract_National", obj.Contract_National);
            Cls.AddParameter("@Contract_Identification", obj.Contract_Identification);
            Cls.AddParameter("@Contract_Company", obj.Contract_Company);
            Cls.AddParameter("@Contract_Address", obj.Contract_Address);
            Cls.AddParameter("@Contract_Phone", obj.Contract_Phone);
            Cls.AddParameter("@Contract_Fax", obj.Contract_Fax);
            Cls.AddParameter("@Contract_TimeWork", obj.Contract_TimeWork);
            Cls.AddParameter("@Contract_Wage", obj.Contract_Wage);
            Cls.AddParameter("@Contract_Vacation", obj.Contract_Vacation);
            Cls.AddParameter("@Contract_Interest", obj.Contract_Interest);
            Cls.AddParameter("@Contract_DateBegin", obj.Contract_DateBegin);
            Cls.AddParameter("@Contract_DateEnd", obj.Contract_DateEnd);
            Cls.AddParameter("@Contract_File", obj.Contract_File);
            Cls.AddParameter("@Contract_Node", obj.Contract_Node);
            return Cls.ExecuteNonQuery("sp_Contract_Update");
        }
        public static bool Delete(EtContract obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@Contract_ID", obj.Contract_ID);
            return Cls.ExecuteNonQuery("sp_Contract_Delete");
        }
        #endregion
    }

    public class EtContract
    {
        public int Contract_ID { get; set; }
        public int TypeContract_ID { get; set; }
        public int Job_ID { get; set; }
        public int Employee_Id { get; set; }
        public string Contract_Code { get; set; }
        public DateTime DateBegin { get; set; }
        public string Contract_Name { get; set; }
        public string Contract_Job { get; set; }
        public string Contract_National { get; set; }
        public string Contract_Identification { get; set; }
        public string Contract_Company { get; set; }
        public string Contract_Address { get; set; }
        public string Contract_Phone { get; set; }
        public string Contract_Fax { get; set; }
        public int Contract_TimeWork { get; set; }
        public float Contract_Wage { get; set; }
        public float Contract_Vacation { get; set; }
        public string Contract_Interest { get; set; }
        public DateTime Contract_DateBegin { get; set; }
        public DateTime Contract_DateEnd { get; set; }
        public string Contract_File { get; set; }
        public string Contract_Node { get; set; }
    }
}